﻿namespace com.vs.General
{
    using com.vs.DataAccess.DO;
    using System;

    public class ExceptionManager
    {
        public const int _AUDITEXCEPTION = 12;
        public const int _CALLSTACK = 11;
        public const int _MAXFIELDLENGTH = 0x7ce;
        public const int _PARM1 = 0;
        public const int _PARM10 = 9;
        public const int _PARM2 = 1;
        public const int _PARM3 = 2;
        public const int _PARM4 = 3;
        public const int _PARM5 = 4;
        public const int _PARM6 = 5;
        public const int _PARM7 = 6;
        public const int _PARM8 = 7;
        public const int _PARM9 = 8;
        public const int _RETURNVALUE = 10;
        public const string EXCEPTION = "Exception";

        private static string ExtractParameter(object[] parameters, int index)
        {
            try
            {
                if (((parameters != null) && (index < parameters.Length)) && (parameters[index] != null))
                {
                    return (!StringManager.IsEmpty(parameters[index].ToString()) ? parameters[index].ToString() : null);
                }
                return null;
            }
            catch
            {
                return null;
            }
        }

        public static void LogException(Session session, Exception exception)
        {
            try
            {
                new AuditLogDO { WAREHOUSE = session.CurrentWarehouse, USER_STAMP = session.User, MESSAGE = exception.Message, VALUE = exception.StackTrace }.Insert(session);
            }
            finally
            {
            }
        }
    }
}

